﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ProductShop
{
    public partial class FormLoginView : Form, ILoginView
    {
        public String LoginEmail
        {
            get
            {
                return tbLoginPassword.Text;
            }
            set
            {
                tbLoginPassword.Text = value;
            }
        }

        public String LoginPassword
        {
            get
            {
                return tbLoginPassword.Text;
            }
            set
            {
                tbLoginPassword.Text = value;
            }
        }

        public String RegistrationEmail
        {
            get
            {
                return tbRegistrationEmail.Text;
            }
            set
            {
                tbRegistrationEmail.Text = value;
            }
        }

        public String RegistrationPassword
        {
            get
            {
                return tbRegistrationPassword.Text;
            }
            set
            {
                tbRegistrationPassword.Text = value;
            }
        }

        public String UserFirstName
        {
            get
            {
                return tbRegistrationUserFirstName.Text;
            }
            set
            {
                tbRegistrationUserFirstName.Text = value;
            }
        }

        public String UserLastName
        {
            get
            {
                return tbRegistrationUserLastName.Text;
            }
            set
            {
                tbRegistrationUserLastName.Text = value;
            }
        }

        public event Action LoginRequested;
        public event Action RegistrationRequested;

        public FormLoginView()
        {
            InitializeComponent();
            btnLogin.Click += (sender, e) => Invoke(LoginRequested);
            btnSubmitRegistration.Click += (sender, e) => Invoke(RegistrationRequested);
        }

        private void Invoke(Action action)
        {
            if (action != null)
            {
                action();
            }
        }

        public void ShowForm()
        {
            Show();
        }

        public void CloseForm()
        {
           Close();
        }
    }
}
